<%@ Page Title="" Language="C#" MasterPageFile="~/SalesOneWeb.Master" AutoEventWireup="true" CodeBehind="SearchVerificationSummary.aspx.cs" Inherits="IronOne.SalesOne.SalesOneWeb.SalesActivity.VerificationSummary" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../StyleSheets/salesOne_txtstyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">


        function dateValidate() {
       
       
        if (Page_IsValid) {
            if (((document.getElementById("ctl00_ContentPlaceHolder1_txtDueDateTo").value) != "") && (document.getElementById("ctl00_ContentPlaceHolder1_txtDueDateFrom").value) != "") {

                var dateFrom = String(document.getElementById("ctl00_ContentPlaceHolder1_txtDueDateFrom").value).split("/");
                var dateTo = String(document.getElementById("ctl00_ContentPlaceHolder1_txtDueDateTo").value).split("/");



                var monthFrom = parseInt(dateFrom[1], 10);
                var monthTo = parseInt(dateTo[1], 10);
                var yearFrom = parseInt(dateFrom[2], 10);
                var yearTo = parseInt(dateTo[2], 10);
                var dayFrom = parseInt(dateFrom[0], 10);
                var dayTo = parseInt(dateTo[0], 10);

                if (yearFrom == yearTo) {

                    if (((monthTo - monthFrom) > 3)) {
                    
                        return validationSummery("Only able to search within 3 months");
                        

                    }
                    else if ((dayTo - dayFrom) > 0 && (monthTo - monthFrom)== 3 ) {
                    return validationSummery("Only able to search within 3 months");                    
                    
                    }                   
                                        
                    return true;
                }
                else if (yearTo - yearFrom == 1) {
                    monthTo = monthTo + 12;

                    if (((monthTo - monthFrom) > 3)) {
                        return validationSummery("Only able to search within 3 months");
                       
                        
                         }
                    else if ((dayTo - dayFrom) > 0 && (monthTo - monthFrom)== 3 ) {
                    return validationSummery("Only able to search within 3 months");                   
                                       
                    } else 
                    {
                    return true; 
                    }

                } else {
                    
                    return validationSummery("You only allow to search within one year");
                    

                }
            }
            
            return validationSummery("Fill relavant fields");
            



        }
        else {
            validationSummery();
            return false;
        }
       }


       window.onload = function() {

           var msg = document.getElementById('ctl00_MasterMsg');
           if (msg && msg.innerHTML != '')
               showMessageBlock();
       }


    

</script>
    
    
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="detailstable">
        <tr>
            <td class="style4" colspan="2" >
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
            </td>
        </tr>
        
        <tr>
            <td height="5px" colspan="2" >
                </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:RadioButton ID="radioButtonDuePolicy" runat="server" Checked="True" 
                    GroupName="buttonGroup" Text="Due Policy" AutoPostBack="True" 
                    oncheckedchanged="radioButtonDuePolicy_CheckedChanged" CssClass="rdbtn"/>
            </td>
            <td >
                <asp:RadioButton ID="radioButtonSC" runat="server" GroupName="buttonGroup" 
                    Text="SC not submitted" AutoPostBack="True" 
                    oncheckedchanged="radioButtonSC_CheckedChanged" CssClass="rdbtn"/>
            </td>
        </tr>
        <tr>
            <td height="5px" class="style6"  >
                </td>
            <td >
                </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:Label ID="Label2" runat="server" Text="Plan Month*:" CssClass="lbl1"></asp:Label>
            </td>
            <td >
                <asp:DropDownList ID="drpMonth" runat="server" CssClass="ddl">
                </asp:DropDownList>
                <asp:DropDownList ID="drpYear" runat="server" CssClass="ddl">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:Label ID="lblBranch" runat="server" Text="Branch Code*:" CssClass="lbl1"></asp:Label>
            </td>
            <td >
                <asp:DropDownList ID="drpBranch" runat="server"  
                    onselectedindexchanged="drpBranch_SelectedIndexChanged" 
                    AutoPostBack="True" CssClass="ddl">
                    <asp:ListItem Value="Select...">Select...</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:Label ID="lblCode" runat="server" Text="Unit Code*:" CssClass="lbl1"></asp:Label>
            </td>
            <td >
                <asp:DropDownList ID="drpUnit" runat="server" 
                    AutoPostBack="True" onselectedindexchanged="drpUnit_SelectedIndexChanged" CssClass="ddl">
                    <asp:ListItem Value="Select...">Select...</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:Label ID="lblSOCode" runat="server" Text="SO Code*:" CssClass="lbl1"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="drpSOcode" runat="server" CssClass="ddl">
                    <asp:ListItem Value="Select...">Select...</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:Label ID="lblDateFrom" runat="server" Text="Due Date From*:" 
                    CssClass="lbl1"></asp:Label>
            </td>
            <td >
                <asp:TextBox ID="txtDueDateFrom" runat="server" CssClass="txtbox"></asp:TextBox>
                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/calander.jpg"/>
                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDueDateFrom" PopupButtonID="Image1" Format="dd/MM/yyyy" >
                </cc1:CalendarExtender>
                <asp:RequiredFieldValidator ID="vldDateFrom" runat="server" 
                    ControlToValidate="txtDueDateFrom">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ControlToValidate="txtDueDateFrom" 
                    ValidationExpression="^([1-9]|0[1-9]|[12][0-9]|3[01])[/.]([1-9]|0[1-9]|1[012])[/.][0-9]{4}$">*</asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="style6" >
                <asp:Label ID="lblDateTo" runat="server" Text="Due Date To*:" CssClass="lbl1"></asp:Label>
            </td>
            <td >
                <asp:TextBox ID="txtDueDateTo" runat="server"  CssClass="txtbox"></asp:TextBox>
                
                <asp:Image ID="Image2" runat="server" ImageUrl="~/images/calander.jpg"/>
                <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtDueDateTo" PopupButtonID="Image2" Format="dd/MM/yyyy" >
                </cc1:CalendarExtender>
                
                <asp:RequiredFieldValidator ID="vldDateTo" runat="server" 
                    ControlToValidate="txtDueDateTo">*</asp:RequiredFieldValidator>
                <asp:CompareValidator ID="cmpVlddate" runat="server" 
                    ControlToCompare="txtDueDateFrom" ControlToValidate="txtDueDateTo" 
                    ErrorMessage="Due date from must be less than Due date to date " 
                    Operator="GreaterThanEqual" Type="Date">*</asp:CompareValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                    ControlToValidate="txtDueDateTo" 
                    ValidationExpression="^([1-9]|0[1-9]|[12][0-9]|3[01])[/.]([1-9]|0[1-9]|1[012])[/.][0-9]{4}$">*</asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="style4" colspan="2" >
                    
                    
                    
            &nbsp;<table cellpadding="0" cellspacing="0" class="style1" style="height: 2px">
                    <tr>
                        <td class="style7">
            
                <asp:Button ID="btnSearch1" runat="server" onclick="btnSearch1_Click" OnClientClick="validationSummery();"  
                    Text="Search" Visible="False" CssClass="btn" Width="76px"/>
                    
                    
                    
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="style6" >
            
                <asp:Button ID="btnSearch" runat="server" Text="Search" OnClientClick="return dateValidate();"
                    onclick="btnSearch_Click"  CssClass="btn" Width="76px"/>
                    
                    
                    
            </td>
            <td >
                <table >
                    </table>
            </td>
        </tr>
    </table>
    <br />
</asp:Content>
